#ifndef SYSTEM_H
#define SYSTEM_H

#include <time.h>

#include <map>
#include <string>

#include "core.h"
#include "procsys.h"

class System
{
public:

    System();

    /* 系统启动时间 */
    time_t getBootTime() const;

    /* 系统中CPU个数 */
    int getCpuCount() const;

    /* 所有CPU时间总和 */
    jiffies_t getTotalCpuTime() const;

    /* 某个CPU启动以来运行时间之和 */
    jiffies_t getTotalCpuTimeOf(int cpuIndex) const;

    /* 系统启动以来经过的jiffies数量 */
    jiffies_t getJiffies() const;

    std::string getUserName(uid_t uid) const;

private:

    void _load_user_names();

    time_t m_boot_time;

    std::map<uid_t, std::string> m_usernames;

    CpuInfoFileContent m_filecontent_cpuinfo;
};

const System SYS;

#endif // SYSTEM_H
